package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

public class UserOrderAccumulatesRequest extends Request{

	private int userId;
	private double sumPrice;
	private String orderId;
	
	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	@Override
	public void parse(HttpServletRequest request) {
		
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), 0);
		this.sumPrice = Double.parseDouble(requestInfo.getParameter(ApiUrlParamEnum.sumPrice.getParamName()));
		this.orderId = requestInfo.getParameter(ApiUrlParamEnum.orderId.getParamName(), "");
		if ( userId < 1 ) {
			throw new RequestIllegalException("error userId: " + userId);
		}
		
		if ( sumPrice < 1 ) {
			throw new RequestIllegalException("error sumPrice: " + sumPrice);
		}
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public double getSumPrice() {
		return sumPrice;
	}

	public void setSumPrice(double sumPrice) {
		this.sumPrice = sumPrice;
	}

	
}
